home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / percnt.zip / CTRLINFO.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-10  |  4KB  |  117 lines

  1. {***************************************************************************
  2.  
  3.     NoMan Custom Control Library            $Version$
  4.     Info Module Unit
  5.     $Author$        $Date$
  6.  
  7.         Copyright 1991 Anthony M. Vitabilea
  8.  
  9.     Unit Description
  10.  
  11.     This Turbo Pascal for Windows unit contains the library's
  12.     information procedures.  This code is common to all classes in
  13.     the DLL.
  14.  
  15.     The library uses straight Windows calls and does NOT use Object-
  16.     Windows.  This is to allow the control to be used by ANY Windows
  17.     program.
  18.  
  19.     This code is adapted from the code that appeared in the July,
  20.     1990 issue of Microsoft Systems Journal article, "Extending the
  21.     Windows 3.0 Interface with Installable Custom Controls" by Kevin
  22.     P. Welch.  It has been extended to comply with the format
  23.     specified by Borland for use with their Resource Workshop
  24.     resource editor.
  25.  
  26. ***************************************************************************}
  27.  
  28. {$C DemandLoad Discardable}
  29. Unit CtrlInfoProcs;
  30. Interface
  31.   Uses WinTypes, CustCntl;
  32.  
  33.   function ListClasses(szAppName:  PChar;
  34.                        wVersion :  word;
  35.                        fnLoad   :  TLoad;
  36.                        fnEdit   :  TEdit):  THandle; export;
  37.   function PercentCtrlInfo:  THandle; export;
  38.  
  39. Implementation
  40.   Uses CtrlCommonDefs, CtrlDlgs, CtrlFlags, Strings, WinProcs;
  41.  
  42.   function ListClasses(szAppName:  PChar;
  43.                        wVersion :  word;
  44.                        fnLoad   :  TLoad;
  45.                        fnEdit   :  TEdit):  THandle;
  46.     var
  47.       ClassList :  THandle;
  48.       PClassList:  PCtlClassList;
  49.  
  50.     begin    { ListClasses }
  51.       ClassList := GlobalAlloc(gmem_Moveable or gmem_ZeroInit,
  52.                    2 + Ctl_NoControls * sizeof(TRWCtlClass));
  53.       if ClassList <> 0
  54.        then
  55.         begin
  56.          PClassList := GlobalLock(ClassList);
  57.          with PClassList^ do
  58.            begin
  59.             nClasses            := Ctl_NoControls;
  60.             @Classes[0].fnInfo  := @PercentCtrlInfo;
  61.             @Classes[0].fnStyle := @PercentCtrlStyle;
  62.             @Classes[0].fnFlags := @PercentCtrlFlags;
  63.             StrCopy(Classes[0].szClass, Pct_Name)
  64.            end
  65.         end;
  66.       ListClasses := ClassList
  67.     end        { ListClasses };
  68.  
  69.   function PercentCtrlInfo:  THandle;
  70.     var
  71.       i        :  integer;
  72.       hCtlInfo :  THandle;
  73.       lpCtlInfo:  PRWCtlInfo;
  74.  
  75.     begin    { PercentCtrlInfo }
  76.         { Allocation memory for information structure }
  77.       hCtlInfo := GlobalAlloc(gmem_Moveable or gmem_ZeroInit,
  78.                   sizeof(TRWCtlInfo));
  79.       if hCtlInfo <> 0
  80.        then
  81.     begin
  82.      lpCtlInfo := GlobalLock(hCtlInfo);    { Lock it down }
  83.      if lpCtlInfo = nil
  84.       then
  85.        begin
  86.         GlobalFree(hCtlInfo);
  87.         hCtlInfo := 0
  88.        end
  89.       else
  90.        with lpCtlInfo^ do
  91.         begin
  92.          wCtlTypes := Pct_NoVariants;
  93.          wVersion  := pct_Version;
  94.          StrCopy(szClass, Pct_Name);
  95.          StrCopy(szTitle, 'Percent Bar Control');
  96.              for i := 0 to Pct_NoVariants - 1 do
  97.                begin
  98.              ctType[i].wType   :=  i;
  99.              ctType[i].wHeight := 24;
  100.              ctType[i].wWidth  := 100;
  101.              ctType[i].dwStyle := Pct_WndStyle[i];
  102.                  if (ctType[i].dwStyle and not PctMask) <> 0
  103.                    then ctType[i].wHeight := ctType[i].wHeight +  8;
  104.                  if (ctType[i].dwStyle and Pct_Axis) <> 0
  105.                    then ctType[i].wHeight := ctType[i].wHeight + 16;
  106.              StrCopy(ctType[i].szDescr, Pct_Variants[i]);
  107.                  ctType[i].hToolBit  := LoadBitmap(HInstance, MakeIntResource(501));
  108.                  ctType[i].hDropCurs := LoadCursor(HInstance, MakeIntResource(500));
  109.                end;
  110.              GlobalUnlock(hCtlInfo)
  111.         end
  112.     end;
  113.       PercentCtrlInfo := hCtlInfo
  114.     end     { PercentCtrlInfo };
  115.  
  116.   end.
  117.